<?php

class Backoffice_Model_FormFlipper extends CC_Backoffice_Form
{
    /** @var Doctrine\ORM\EntityManager */
    protected $_em;
    
    public function __construct($options = null, Doctrine\ORM\EntityManager $em = null)
    {
        parent::__construct($options);
        $this->_em = $em;
        
        // Flag dropdown
        $flag = new CC_Form_FlagSelect('flag', $this->_em);
        $flag->setLabel('Flag')
             ->setRequired(true)
             ->addErrorMessage("A flag needs to be selected");
        
        // Privilege dropdown
        $privilege = new Zend_Form_Element_Select('privilege');
        $privilege->setLabel('Privilege')
                  ->addMultiOption('', 'Please select a privilege...')
                  ->setRegisterInArrayValidator(false)
                  ->setRequired(true)
                  ->addErrorMessage("A privilege needs to be selected");
        
        // Group dropdown
        $group = new CC_Form_GroupSelect('group', $this->_em);
        $group->setLabel('Group')
              ->setRequired(true)
              ->addErrorMessage("A group needs to be selected");
        
        // Allow checkbox
        $allow = new Zend_Form_Element_Checkbox('allow');
        $allow->setLabel('Allow');
        
        // Submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Create Flipper');
        
        // Add elements to form
        $this->addElements(array(
                $flag, 
                $privilege, 
                $group, 
                $allow,
                $submit
            )
        );
    }
}
